package com.gitee.melin.bee.core.jdbc.dialect;

import com.gitee.melin.bee.core.jdbc.enums.DataSourceType;
import com.gitee.melin.bee.core.jdbc.relational.*;
import com.gitee.melin.bee.core.jdbc.QueryResult;

import java.sql.Statement;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public interface JdbcDialect extends AutoCloseable {

    DataSourceType getDataSourceType();

    MetaDataSource testConnection();

    DatabaseVersion getDatabaseVersion();

    List<String> getDatabases();

    List<String> getSchemas();

    MetaTable getSchemaTable(String schemaName, String tableName);

    List<MetaTable> getSchemaTables(String schemaName);

    List<MetaColumn> getPrimaryKeys(String schemaName, String tableName);

    List<MetaColumn> getSchemaColumns(String schemaName, String tableName);

    String getCreateTableScript(String schemaName, String tableName);

    Statement getQueryStatement();

    CompletableFuture<QueryResult> asyncQuery(String sql);

    CompletableFuture<QueryResult> asyncQuery(String schema, String sql);

    CompletableFuture<QueryResult> asyncQuery(String sql, int maxRecords);

    CompletableFuture<QueryResult> asyncQuery(String schema, String sql, int maxRecords);

    QueryResult query(String sql);

    QueryResult query(String schema, String sql);

    QueryResult query(String sql, int maxRecords);

    QueryResult query(String schema, String sql, int maxRecords);

    Boolean execute(String sql);

    Boolean execute(String schema, String sql);

    CompletableFuture<Boolean> asyncExecute(String sql);

    CompletableFuture<Boolean> asyncExecute(String schema, String sql);

    Integer executeUpdate(String sql, Object... params);

    Integer executeUpdate(SchemaIdentifier schema, String sql, Object... params);

    CompletableFuture<Integer> asyncExecuteUpdate(String sql, Object... params);

    CompletableFuture<Integer> asyncExecuteUpdate(SchemaIdentifier schema, String sql, Object... params);

}
